<%@ page import="com.h.heal.entity.Admin" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html lang="zh">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>Heal视频编辑功能</title>
    <jsp:include page="../../common_css.jsp"/>

    <style>
        .form-control {
            width: 30%;
        }

        .card {
            background: rgba(255,255,255,0);
        }
    </style>
</head>
<body style="background: linear-gradient(to top right, #a1ffce 0%, #faffd1 100%)">
<div class="container-scroller">
    <!-- partial:partials/_navbar.html -->
    <jsp:include page="../../top_user.jsp"/>

    <!-- partial -->
    <div class="container-fluid page-body-wrapper">
        <!-- partial:partials/_sidebar.html -->
        <jsp:include page="../../left_user.jsp"/>
        <!-- partial -->
        <div class="main-panel">
            <div class="row">
                <div class="col-md-12 stretch-card">
                    <div class="card">
                        <div class="card-body">

                            <div class="table-responsive" align="center">


                                <form id="frm" class="form-signin">
                                    <h1 class="h3 mb-3 font-weight-normal">编辑视频信息</h1>
                                    <label for="input_video_vid" class="sr-only">视频编号vid</label>
                                    <%--              获得视频编号                          value="${video.video_vid}--%>
                                    <input type="text" id="input_video_vid" name="video_vid" class="form-control"
                                           value="${video.video_vid}" placeholder="vid" readonly>

                                    <label for="input_video_vname" class="sr-only">视频标题</label>
                                    <input type="text" id="input_video_vname" name="video_vname" class="form-control"
                                           value="${video.video_vname}" placeholder="vname">

                                    <label for="input_video_uid" class="sr-only">作者id</label>
                                    <input type="text" id="input_video_uid" name="video_uid"
                                           class="form-control" value="${video.video_uid}" placeholder="uid" readonly>

                                    <label for="input_video_timestamp" class="sr-only">发布时间</label>
                                    <input type="text" id="input_video_timestamp" name="video_timestamp"
                                           class="form-control" value="${video.video_timestamp}" placeholder="timestamp"
                                           readonly>


                                    <label for="input_video_vv" class="sr-only">播放量</label>
                                    <input type="text" id="input_video_vv" name="video_vv"
                                           class="form-control" value="${video.video_vv}" placeholder="vv" readonly>

                                    <label for="input_video_like" class="sr-only">点赞数</label>
                                    <input type="text" id="input_video_like" name="video_like"
                                           class="form-control" value="${video.video_like}" placeholder="like" readonly>

                                    <label for="input_video_url" class="sr-only">URL</label>
                                    <input type="text" id="input_video_url" name="video_url"
                                           class="form-control" value="${video.video_url}" placeholder="URL">
                                    <label for="input_video_img" class="sr-only">视频封面</label>
                                    <input type="text" id="input_video_img" name="video_img"
                                           class="form-control" value="${video.video_img}" placeholder="视频封面">

                                    <button class="btn btn-lg btn-primary btn-block" type="button" onclick="doEdit()"
                                            style="width: 30%">编辑
                                    </button>
                                </form>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>


        <jsp:include page="../../footer.jsp"/>
    </div>
    <!-- main-panel ends -->
</div>
<!-- page-body-wrapper ends -->
</div>
<!-- container-scroller -->
<jsp:include page="../../common_js.jsp"/>
</body>

</html>

<script>
    function doEdit() {
        //推荐前端js验证字段

        var input_video_vid = $("#input_video_vid").val();

        if (input_video_vid == '') {
            alert("视频编号不能为空");
        } else {
            $.ajax(
                {
                    type: "post",
                    url: "/video/doEdit",
                    data: $("#frm").serialize(),
                    async: false,  //使用ajax同步提交数据
                    success: function (response) {
                        if (response == "ok") {
                            // alert("视频编辑成功,1秒后跳转到视频列表");
                            setTimeout(window.location.href = "/video/user/main", 500);
                        } else {
                            alert("编辑失败，请联系管理员....");
                        }
                    }
                }
            );
        }
    }
</script>

